page.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use client";
  2. import { userInfoApi } from "@/api/login";
  3. import { getUserMoneyApi, UserVipInfo } from "@/api/user";
  4. import { server } from "@/utils/client";
  5. import { useRequest } from "ahooks";
  6. import ItemCom from "./component/ItemCom";
  7. import ModalCom from "./component/ModalCom";
  8. import "./page.scss";
  9. import { ProfileHeader } from "./ProfileHeader";
  10. /**
  11. * @description 前台用户VIP信息 接口地址:https://app.apifox.com/link/project/4790544/apis/api-201160713
  12. */
  13. const getVipApi = async () => {
  14. return server
  15. .request<UserVipInfo>({
  16. url: "/v1/api/user/user_vip_info",
  17. method: "POST",
  18. })
  19. .then((res) => {
  20. if (res.code === 200) return res.data;
  21. });
  22. };
  23. const Profile = () => {
  24. const { data: userInfo } = useRequest<any, any>(userInfoApi, {
  25. pollingErrorRetryCount: 1,
  26. pollingWhenHidden: false,
  27. });
  28. const { data: userMoney } = useRequest<any, any>(getUserMoneyApi, {
  29. pollingErrorRetryCount: 1,
  30. pollingWhenHidden: false,
  31. });
  32. const { data: userVip } = useRequest<any, any>(getVipApi, {
  33. pollingErrorRetryCount: 1,
  34. pollingWhenHidden: false,
  35. });
  36. return (
  37. <div className="profile-box">
  38. <ProfileHeader userInfo={userInfo} userMoney={userMoney} userVip={userVip!} />
  39. <ItemCom />
  40. <ModalCom />
  41. </div>
  42. );
  43. };
  44. export default Profile;